<table cellpadding="0" cellspacing="0">
	<tbody>
        <tr>
            <td class="leftside">
           		<?php require_once("menu.php");?>
            </td>
            <td class="rightside">      
                <div class="box" style="margin-left:10px; margin-right: 10px; float:left;">
                	<div id='title_menu' class="ui-corner-top">ตรวจสอบการโอนเงิน</div>  
                    <div class="content" style="min-height: 150px;">
                    <?php
                    $sql = 'SELECT * FROM order_confirm';
					$q = $db->select_query($sql);
					?>
                    <table class="display" id="check_transfer_list" >
                        <thead>
                          <tr align="center">
                            <th width="70">Invoice</th>
                            <th width="100">รูปแบบโฆษณา</th>
                            <th width="105">วันที่ทำรายการ</th>
                            <th width="70">เวลา</th>
                            <th width="70">ค่าบริการ</th>
                            <th width="110">จำนวนเงินที่โอน</th>
                            <th width="90">แจ้งเมื่อ</th>
                            <th width="80">รายละเอียด</th>                            
                          </tr>
                        </thead>
                        <tbody>
                        <?php
                        while($rs =  $db->fetch($q)){
						?>
                        	<tr>
                            	<td align="center"><strong><?php echo $rs['invoice'];?></strong></td>
                                <td align="center"><strong><?php echo $rs['type'];?></strong></td>
                                <td align="center"><strong><?php echo ThaiTimeConvert($rs['transfer_date'],0,0);?></strong></td>
                                <td align="center"><strong><?php echo $rs['transfer_time'];?></strong></td>
                                <td align="center"><strong style="color:red;"><?php echo $rs['total_price'];?></strong></td>
                              	<td align="center"><strong style="color:red;"><?php echo $rs['transfer_price'];?></strong></td>
                                <td align="center"><strong style="color:red;"><?php echo ThaiTimeConvert(strtotime($rs['updated_at']),0,1);?></strong></td>
                                <td align="center">
                                	<a href="?m=bank&p=check_transfer&tid=<?php echo $rs['id'];?>">
                                    	<img src="images/info.png" title="รายะละเอียดเพิ่มเติม" />
                                    </a>
                              	</td>
                            </tr>
                       	<?php
						}
						?>
                        </tbody>
                    </table>
                   	</div>
               	</div>
                <?php if(isset($_GET['tid'])){?>
                <div class="box" style="margin-left:10px; margin-right: 10px; float:left;">
                	<div id='title_menu' class="ui-corner-top">รายละเอียดเพิ่มเติม</div>  
                    <div class="content" style="min-height: 150px;">
                    <?php
                    	$sql = 'SELECT
								  `banks`.`name`, `order_confirm`.*, `order_ads`.`ads_id`
								FROM
								  `order_confirm` INNER JOIN
								  `banks` ON `banks`.`id` = `order_confirm`.`transfer_bank` INNER JOIN
								  `order_ads` ON `order_ads`.`invoice` = `order_confirm`.`invoice`
								WHERE
								  `order_confirm`.`id` ='.$_GET['tid'];
						$getpos_sql = 'SELECT
										`order_ads`.`ads_id`
									  FROM
										`order_confirm` INNER JOIN
										`order_ads` ON `order_ads`.`invoice` = `order_confirm`.`invoice`
									  WHERE
										`order_confirm`.`id` ='.$_GET['tid'];
						$detail_q = $db->select_query($sql);
						$pos_q	= $db->select_query($getpos_sql);
						$position = $db->fetch($pos_q);
						$detail =  $db->fetch($detail_q);
						
						$ads_code = explode('#',$detail['ads_id']);
						if($detail['type']=='ปักหมุด'){
							$advertise = mysql_query('SELECT position_id FROM advertise WHERE id="'.$ads_code[0].'"');
							$expire = mysql_fetch_assoc($advertise);
							$pos = $expire['position_id'];
						}else{
							$advertise = mysql_query('SELECT position_id FROM banners WHERE banner_id="'.$ads_code[0].'"');
							$expire = mysql_fetch_assoc($advertise);
							$pos = $expire['position_id'];
						}
						$getpos = mysql_query('SELECT position_name FROM positions WHERE id='.$pos);
						$position = mysql_fetch_assoc($getpos);
					?>
                    <table class="list">
                        <thead>
                          <tr align="center">
                          	<td width="50">โอนไปที่ธนาคาร</td>
                            <td width="50">โอนจากธนาคาร</td>
                            <td width="60">สาขา</td>
                            <td width="60">ตำแหน่ง</td>
                            <td width="110">รายละเอียดเพิ่มเติม</td>                         
                          </tr>
                        </thead>
                        <tbody>
                        	<tr align="center">
                            	<td><strong><?php echo $detail['name'];?></strong></td>
                            	<td><strong><?php echo $detail['from_bank'];?></strong></td>
                                <td><strong><?php echo $detail['from_branch'];?></strong></td>
                                <td><strong><?php echo $position['position_name'];?></strong></td>
                                <td><strong><?php echo $detail['detail'];?></strong></td>
                                
                            </tr>
                        </tbody>
                    </table>
                    </div>
              	</div>
               <?php }?>
            </td>
        </tr>
   	</tbody>
</table>
<script type="text/javascript">
$(function(){
	oTable = $('#check_transfer_list').dataTable({
		"bJQueryUI": true,
		"sPaginationType": "full_numbers"
	});
});
</script>